
package todolist.personalization;

/**
 * Controls application behaviour related to Date/Time Description input and display.
 * Singleton class.
 * Currently allows getting only, may allow reading/setting/writing in the future.
 * @see todolist.entity.DateTimeEntity
 * @author Ivan
 */
public class DateTimeDescriptionCustomizer {

	// handle singleton instance

	private static DateTimeDescriptionCustomizer _objDTDC;

	public static DateTimeDescriptionCustomizer getInstance() {
		if (_objDTDC == null)
			_objDTDC = new DateTimeDescriptionCustomizer();
		return _objDTDC;
	}

	// input DT Descriptions
	
	private static final String[] DT_INPUT_START = {
		"after", "starting", "starts", "since", "from", ">"};
	private static final String[] DT_INPUT_END = {
		"before", "ending", "ends", "until", "to", "due", "by", "at", "on", "<", "@"};
	private static final String[] DT_INPUT_NON_STRICT = {
		"around", "about", "near", "~", "approximately"};
	private static final String[] DT_INPUT_DESCRIPTORS = {
		"week of", "month of"};
	
	// display DT Descriptions
	
	private static final String DT_DISPLAY_START_BOTH = "from";
	private static final String DT_DISPLAY_START_ONE = "starting";
	private static final String DT_DISPLAY_END_BOTH = "to";
	private static final String DT_DISPLAY_END_ONE = "due";
	private static final String DT_DISPLAY_NON_STRICT = "around";
	
	// input DT Descriptions
	
	/**
	 * Returns all keywords that classify a DateTimeEntity as a Start Date.
	 */
	public String[] getDTInputStart() {
		return DT_INPUT_START;
	}

	/**
	 * Returns all keywords that classify a DateTimeEntity as an End Date.
	 */
	public String[] getDTInputEnd() {
		return DT_INPUT_END;
	}

	/**
	 * Returns all allowed keywords that classify a DateTimeEntity as not Strict.
	 */
	public String[] getDTInputNonStrict() {
		return DT_INPUT_NON_STRICT;
	}

	/**
	 * Returns first found DateTimeEntity Descriptor that matches input.
	 */
	public String findDTInputDescriptor(String pstrInput) {
		for (String strDescriptor : DT_INPUT_DESCRIPTORS)
			if (strDescriptor.equals(pstrInput))
				return strDescriptor;
		return null;
	}

	/**
	 * Returns all allowed DateTimeEntity Descriptors.
	 */
	public String[] getDTInputDescriptors() {
		return DT_INPUT_DESCRIPTORS;
	}

	// display DT Descriptions

	/**
	 * Prefix for Start Date, with a corresponding End Date.
	 */
	public String getDTDisplayBothStartDate() {
		return DT_DISPLAY_START_BOTH;
	}

	/**
	 * Prefix for Start Date, without End Date.
	 */
	public String getDTDisplayOneStartDate() {
		return DT_DISPLAY_START_ONE;
	}

	/**
	 * Prefix for End Date, with a corresponding Start Date.
	 */
	public String getDTDisplayBothEndDate() {
		return DT_DISPLAY_END_BOTH;
	}

	/**
	 * Prefix for End Date, without Start Date.
	 */
	public String getDTDisplayOneEndDate() {
		return DT_DISPLAY_END_ONE;
	}

	/**
	 * Prefix for non-Strict DT Description.
	 */
	public String getDTDisplayNonStrict() {
		return DT_DISPLAY_NON_STRICT;
	}
	
}
